package com.gemo.demo.mapper;

import com.gemo.demo.entiy.News;
import com.gemo.demo.util.PageUtil;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface NewsMapper {
    //查询
    @Select("<script>" +
            "select * from news where status=1"+
            "<if test=\"tid!=0\">" +
            " and tid=#{tid}" +
            "</if>"+
            "<if test=\"word!=null and word!=''\">" +
            " and title like \"%${word}%\"" +
            "</if>"+
            "</script>")
    List<News> select(@Param("tid") int tid, @Param("word") String word);
    //假删除 将根据id status置为0
    @Update("update news set status=0 where id=#{id}")
    int updateById(@Param("id") int id);
    @Select("select * from news where id=#{id}")
    News selectById(@Param("id") int id);
    @Insert("insert into news values(id=#{id},title=#{title},img=#{img},detail=#{detail}," +
            "publishdate=#{publishdate},tid=#{tid},tname=#{tname},status=1)")
    int insert(News news);
}
